/*
 * HeaderChunk.hpp
 *
 *  Created on: 16 nov. 2010
 *      Author: guillaume
 *
 *
   header_chunk = "MThd" + <header_length> + <format> + <n> + <division>

 */

#ifndef HEADERCHUNK_HPP_
#define HEADERCHUNK_HPP_

class HeaderChunk {
public:
	HeaderChunk();
	virtual ~HeaderChunk();

	inline unsigned short int getDivision() const
    {
        return division;
    }

    inline unsigned short int getFormat() const { return format; }

    inline unsigned char* getMthd() { return mthd; }

    inline unsigned long int getHeaderLength() const { return headerLength; }

    inline unsigned short int getNumberOfTracks() const { return numberOfTracks; }

    void setDivision(unsigned char* buffer);

    void setFormat(unsigned char* buffer);

    void setMthd(unsigned char* mthd);

    /**
     * Following method fills the headerLength with its value. It should always be Ox0006 in a HeaderChunk
     */
    void setHeaderLength(unsigned char* buffer);

    void setNumberOfTracks(unsigned char* buffer);
    //TODO
	//Methode qui décale les bit d'un char et stocke le nombre obtenu dans un long


private:
    //mthd is a tab which should containing the 4 following characters : "Mthd"
	unsigned char mthd[4];
	//headerLength gives number of the bytes following himself in the chunk
	unsigned long int headerLength;
	//Format give the type of midi file we have. Could be 0, 1 or 2
	unsigned short int format;
	unsigned short int numberOfTracks;
	unsigned short int division;

};

#endif /* HEADERCHUNK_HPP_ */
